home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Networking / MoreNetworkSetup / MoreTextUtils / MoreTextUtils.h < prev   
Encoding:
C/C++ Source or Header  |  2000-09-28  |  3.8 KB  |  111 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        MoreTextUtils.h
  3.  
  4.     Contains:    
  5.  
  6.     Written by:    Pete Gontier
  7.  
  8.     Copyright:    Copyright (c) 1998 Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.  
  20.          <4>     20/3/00    Quinn   Added MoreReplaceText and its support routines.  Added
  21.                                     MoreStrLen.  Tidied up a little.
  22.          <3>     21/4/99    Quinn   Added ValidStringListHandle.
  23.          <2>    11/11/98    PCG     fix headers
  24.          <1>    11/10/98    PCG     first big re-org at behest of Quinn
  25.  
  26.     Old Change History (most recent first):
  27.  
  28.          <5>    10/11/98    Quinn   Convert "MorePrefix.h" to "MoreSetup.h".
  29.          <4>    10/23/98    PCG     add GetPascalStringFromLongDouble
  30.          <3>      9/9/98    PCG     re-work import and export pragmas
  31.          <2>     7/24/98    PCG        coddle linker (C++, CFM-68K)
  32.          <1>     6/16/98    PCG     initial checkin
  33. */
  34.  
  35. #pragma once
  36.  
  37. /////////////////////////////////////////////////////////////////
  38.  
  39. // MoreIsBetter Setup
  40.  
  41. #include "MoreSetup.h"
  42.  
  43. // Mac OS Interfaces
  44.  
  45. #include <TextUtils.h>
  46. #include <fp.h>
  47.  
  48. /////////////////////////////////////////////////////////////////
  49.  
  50. typedef struct
  51. {
  52.     UInt16                count;
  53.     ConstStr255Param    list [ ];
  54.  
  55.     // followed by packed strings from 'STR#' resource
  56. }
  57. *tStringListP, **tStringListH;
  58.  
  59. #ifdef __cplusplus
  60.     extern "C" {
  61. #endif
  62.  
  63. #pragma import on // for clients
  64. #pragma export on // for building a library
  65.  
  66. pascal OSErr    GetPascalStringFromLongDouble    (long double, SInt8 precision, StringPtr);
  67.  
  68. pascal OSErr    GetNewStringList                (short resID, tStringListP *newStringList);
  69.  
  70. pascal OSErr    NewStringListHandle                (Handle *); // can use DisposeHandle to dispose
  71.  
  72. pascal OSErr    AppendStringToListHandle        (ConstStr255Param, Handle);
  73.  
  74. pascal Boolean    ValidStringListHandle(Handle stringList);
  75.     // Return true if stringList is a valid string list (STR#).
  76.     // This is useful when you get a string list out of a resource
  77.     // (such as a preferences file) and you want to make sure that
  78.     // you can safely operate on it with the other string list routines
  79.     // in this file.
  80.  
  81. pascal OSErr    NewStringPtr                    (ConstStr255Param, UInt8 maxSize, StringPtr *result);
  82.  
  83. extern pascal OSStatus InitMoreTextUtils(void);
  84.     // Initialises this module.  Calling this routine is not strictly speaking
  85.     // necessary because each entry point will perform whatever initialisation
  86.     // it requires, but it can be useful to detect any initialisation errors.
  87.     
  88. extern pascal void TermMoreTextUtils(void);
  89.     // Terminates this module.  This is not necessary for application clients,
  90.     // but very important for non-application (code resources, shared libraries,
  91.     // etc) clients.
  92.  
  93. extern pascal void MoreReplaceText(Str255 baseText, ConstStr255Param substitutionText, ConstStr15Param key);
  94.     // Works like the Mac OS system call ReplaceText, except that:
  95.     // 
  96.     // o You don’t have to set up thePort before calling this routine.  The
  97.     //   routine will automatically switch to a port configured to use
  98.     //   the system font.  Thus the baseText is assumed to be in the system
  99.     //   script.
  100.     //
  101.     // o For convenience, the parameters are strings rather than handles.
  102.  
  103. extern pascal ByteCount MoreStrLen(const char *str);
  104.     // strlen for those whose don’t do StdCLib.
  105.  
  106. #pragma import reset // for clients
  107. #pragma export reset // for building a library
  108.  
  109. #ifdef __cplusplus
  110.     }
  111. #endif